package com.cip.master.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.cip.admin.dao.impl.CipHibernateDAOSupport;
import com.cip.master.dao.PaymentDAO;
import com.cip.master.model.Examination;
import com.cip.master.model.Holiday;
import com.cip.master.model.Payment;

public class PaymentDAOImpl  extends CipHibernateDAOSupport implements PaymentDAO {
	
	public Payment savePayment(Payment payment){
		getHibernateTemplate().saveOrUpdate(payment);
		return payment;
	}
	
	public Payment getPaymentById(int id) throws Exception{
		HibernateTemplate hibernateTemplate = getCipHibernateTemplate();	
		return hibernateTemplate.get(Payment.class,id);
	}
	public List<Payment> getAllPaymentsByUser(String username) throws Exception {
		System.out.println("username===>"+username);
		String queryString="select payment from Payment as payment where payment.userId='"+username+"'";
		HibernateTemplate hibernateTemplate = getCipHibernateTemplate();		
	    List<Payment> paymentList = hibernateTemplate.find(queryString);
		return paymentList;
	}
	
	public List<Payment> getAllPaymentsByTenant(int tenantId) throws Exception {
		System.out.println("tenantId===>"+tenantId);
		String queryString="select payment from Payment as payment where payment.tenantId="+tenantId;
		HibernateTemplate hibernateTemplate = getCipHibernateTemplate();		
	    List<Payment> paymentList = hibernateTemplate.find(queryString);
		return paymentList;
	}
	
	public List<Payment> getAllPayments() throws Exception {
		System.out.println("tenantId===>");
		String queryString="select payment from Payment as payment";
		HibernateTemplate hibernateTemplate = getCipHibernateTemplate();		
	    List<Payment> paymentList = hibernateTemplate.find(queryString);
		return paymentList;
	}

}
